package com.xyht.sca_s.student_manage_system.modules.useMoneyApplication.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.useMoneyApplication.entity.SmsUseMoneyApplicationProcess;
import com.xyht.sca_s.student_manage_system.modules.useMoneyApplication.mapper.SmsUseMoneyApplicationProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UseMoneyApplication {
    @Autowired
    private SmsUseMoneyApplicationProcessMapper smsUseMoneyApplicationProcessMapper;

    private String[] departmentNameArray = {"部门负责人", "分管领导", "财务",
            "领导"};

    @Bean
    public void useMoneyApplicationInit() {
        List<SmsUseMoneyApplicationProcess> processList =
                smsUseMoneyApplicationProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsUseMoneyApplicationProcess addProcess =
                        new SmsUseMoneyApplicationProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setIsUse(true);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsApplicationEdit(false);
                addProcess.setSort(sort++);
                smsUseMoneyApplicationProcessMapper.insert(addProcess);
            }


        }
    }


}
